// 从vue-router库中导入createRouter和createWebHistory函数
import {createRouter,createWebHistory } from 'vue-router';

// 导入组件
import Layout from '../views/Layout.vue';
import Login from '../views/Login.vue';

// 导入子路由
import ArticleCategory from '../views/article/ArticleCategory.vue';
import ArticleManage from '../views/article/ArticleManage.vue';
import UserAvatar from '../views/user/UserAvatar.vue';
import UserInfo from '../views/user/UserInfo.vue';
import UserResetPassword from '../views/user/UserResetPassword.vue';


// 定义路由数组，每个路由对象包含路径和对应的组件
const routes = [
    // 根路径'/'对应Layout组件
    {path:'/',component:Layout,
        redirect: '/article/category',
        children:[
            // 子路由，对应ArticleCategory组件
            {path:'/article/category',component:ArticleCategory},
            // 子路由，对应ArticleManage组件
            {path:'/article/manage',component:ArticleManage},
            // 子路由，对应UserAvatar组件
            {path:'/user/avatar',component:UserAvatar},
            // 子路由，对应UserInfo组件
            {path:'/user/info',component:UserInfo},
            // 子路由，对应UserResetPassword组件
            {path:'/user/resetPassword',component:UserResetPassword}
        ]
        
    },
    // 路径'/login'对应Login组件
    ,{path:'/login',component:Login}
];

// 创建路由器实例，使用createWebHistory函数生成的历史记录和预定义的路由配置
const router = createRouter({
    history:createWebHistory(),
    routes
});

// 导出默认的路由器实例，供其他模块使用
export default router;